<template>
    <div>
        <input type="text" v-model="que.xmmx">项目名称
                    <input type="button" value="查询" @click="xs">

        <table>
            
            <thead>
                <tr >
                    <td>
                        <input type="checkbox" >
                    </td>
                    <td>项目编号</td>
                    <td>项目名称</td>
                    <td>启用/禁用</td>
                    <td>状态</td>
                    <td>服务人数</td>
                    <td>服务时长</td>
                    <td>佣金</td>
                    <td>操作</td>
                   
                </tr>
            </thead>
            <tbody>
                <tr v-for="m in data">
                    <td>
                        <input type="checkbox" >
                    </td>
                    <td>{{m.kfbh}}</td>
                    <td>{{m.xmmc}}</td>
                    <td>{{m.zt}}</td>
                    <td>{{m.sc}}</td>
                    <td>{{m.fwrs}}</td>
                    <td>{{m.fwsc}}</td>
                    <td>{{m.yj}}</td>
                    <td>
                    <input type="button" value="删除" @click="sc()">
                    <input type="button" value="启用" @click="xs">

                    </td>
                   
                </tr>
            </tbody>
        </table>
        <input type="button" value="首页" @click="page(1)">
        <input type="button" value="上一页" @click="page(2)">
        <input type="button" value="下一页" @click="page(3)">
        <input type="button" value="尾页" @click="page(4)">
        共{{ws.count}}条，每页{{que.page}}条，共{{que.index}}/{{ws.plist}}页{{ws.plist}}

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';

const data=ref([{
    "xmid": 1,
      "kfbh": "",
      "xmmc": "",
      "zt": true,
      "sc": true,
      "fwrs": 0,
      "fwsc": 0,
      "yj": 0
}])
const date=ref({
    "xmid": 1,
    
})
const  sc=()=>{
  
    if(confirm("确认删除吗"))
    axios.post("https://localhost:7189/api/kf/sc",date.value).then(res=>{
            if(res.data>0){
                alert("删除成功");
                xs();
            }else{
                alert("删除失败");

            }
    })
}

const  qy=()=>{
  

    data.value
}
const  que=ref({
    index:1,
    page:3,
    xmmx:""
})
const page=(a:any)=>{
    if(a==1){
        que.value.index=1
        xs();
    }
    if(a==2){
        que.value.index-=1
        xs();
    }
    if(a==3){
        que.value.index+=1
        xs();
    }
    if(a==4){
        que.value.index=ws.value.plist
        xs();
    }
}

const ws=ref({
    count:0,
    plist:0
})
onMounted(()=>{
    xs()
})

const xs=()=>{
    axios.get("https://localhost:7189/api/kf/xs",{params:que.value}).then(res=>{
        data.value=res.data.plist


        ws.value.count =res.data.count
        ws.value.plist =   Math.ceil(res.data.count/que.value.index)
    })
}


</script>

<style scoped>

</style>